import SuperScrollView from "../../Script/components/SimpleScrollView";


const { ccclass, property } = cc._decorator;

@ccclass
export default class FrameLoading extends cc.Component {

    @property(SuperScrollView)
    ndSv: SuperScrollView = null;

    @property(cc.EditBox)
    numEdit: cc.EditBox = null;

    dataList: any[] = [];

    start() {
        for (let i = 1; i <= 500; i++) {
            this.dataList.push(i);
        }
    }


    commonLoadingItems() {

        let cb = () => {
            this.ndSv.scrollToIndex(300);
        }

        this.ndSv.setData(this.dataList.slice(), false, cb);
    }

    frameLoadingItems() {


        let cb = () => {
            this.ndSv.scrollToIndex(300);
        }

        this.ndSv.setData(this.dataList.slice(), true, cb);
    }

    deleteAllItems() {
        this.ndSv.setData([], false);
    }

    deleteSingle() {
        let numStr = this.numEdit.string;

        let index = Number(numStr);

        this.ndSv.deleteItem(index);
    }

    updateSingle() {
        let numStr = this.numEdit.string;

        let index = Number(numStr);

        this.ndSv.updateItem(index, 999);
    }
}
